//导入 fs 模块
import fs from 'fs'

//封装一个方法,返回一个Promise对象

function getPromise(url) {
    return new Promise((resolve, reject) => {
        fs.readFile(url, 'utf8', (err, data) => {
            resolve(data)//成功的结果
        })
    })
}

// 调用
getPromise('./txt/a.txt').then(res => {
    console.log(res);
    return getPromise('./txt/b.txt')
}).then(res => {
    console.log(res);
    return getPromise('./txt/c.txt')
}).then(res => {
    console.log(res);
})
